package com.retirement.web.controller.csd;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.retirement.common.annotation.Log;
import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.enums.BusinessType;
import com.retirement.csd.domain.OdsServe;
import com.retirement.csd.service.IOdsServeService;
import com.retirement.common.utils.poi.ExcelUtil;
import com.retirement.common.core.page.TableDataInfo;

/**
 * 服务类别Controller
 *
 * @author ruoyi
 * @date 2024-03-13
 */
@RestController
@RequestMapping("/csd/orderServe")
public class OdsServeController extends BaseController
{
    @Autowired
    private IOdsServeService odsServeService;

    /**
     * 查询服务类别列表
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdsServe odsServe)
    {
        startPage();
        List<OdsServe> list = odsServeService.selectOdsServeList(odsServe);
        return getDataTable(list);
    }
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:list')")
    @GetMapping("/listAll")
    public TableDataInfo listALl(OdsServe odsServe)
    {
        List<OdsServe> list = odsServeService.selectOdsServeList(odsServe);
        return getDataTable(list);
    }

    /**
     * 导出服务类别列表
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:export')")
    @Log(title = "服务类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OdsServe odsServe)
    {
        List<OdsServe> list = odsServeService.selectOdsServeList(odsServe);
        ExcelUtil<OdsServe> util = new ExcelUtil<OdsServe>(OdsServe.class);
        util.exportExcel(response, list, "服务类别数据");
    }

    /**
     * 获取服务类别详细信息
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(odsServeService.selectOdsServeById(id));
    }

    /**
     * 新增服务类别
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:add')")
    @Log(title = "服务类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OdsServe odsServe)
    {
        return toAjax(odsServeService.insertOdsServe(odsServe));
    }

    /**
     * 修改服务类别
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:edit')")
    @Log(title = "服务类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdsServe odsServe)
    {
        return toAjax(odsServeService.updateOdsServe(odsServe));
    }

    /**
     * 删除服务类别
     */
//    @PreAuthorize("@ss.hasPermi('csd:orderServe:remove')")
    @Log(title = "服务类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(odsServeService.deleteOdsServeByIds(ids));
    }
}
